<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"  media="all">
    <script th:src="@{/jquery/jquery-3.3.1.js}" type="text/javascript"></script>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <script th:src="@{/common/layuiload.js}" type="text/javascript"></script>
    <title>编辑</title>
    <style>
    /*css*/
    </style>

</head>
<body style="margin-left:20px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>编辑</legend>
</fieldset>
<form id="comitform" class="layui-form" th:action="@{/roles/editDo}" method="post">
    <input type="hidden" id="uid" th:value="${roles.id}" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">角色名字</label>
        <div class="layui-input-block">
            <input type="text" name="name" th:value="${roles.name}" lay-verify="title" autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <input type="text" name="desc" th:value="${roles.desc}" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属小组</label>
        <div class="layui-input-block" lay-filter="team">
            <select>
                <option th:each="t:${team}" th:value="${t.id}+','+${t.team}" th:text="${t.team}" th:selected="${t.id} eq ${roles.pid}"></option>
            </select>
        </div>
    </div>
    <input type="hidden" th:value="${roles.pid}" name="pid" id="pid">
    <input type="hidden" th:value="${roles.team}" name="team" id="team">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
        </div>
    </div>
</form>
</body>
<script>
    //js
    layui.use('form', function() {
        var form = layui.form;
        form.on('select(team)', function (data) {
            setpid(data.value);
        });
    });
    function setpid(val) {
        var ss =val.split(",");
        $("#pid").val(ss[0]);
        $("#team").val(ss[1]);
    }
</script>
</html>